//
//  HOGlobalData.m
//  WeiDu
//
//  Created by foguo-mac-1 on 23/11/2017.
//  Copyright © 2017 WeiDu. All rights reserved.
//

#import "HOGlobalData.h"
#import "HOConstants.h"

static HOGlobalData *_instance;
@implementation HOGlobalData

+ (HOGlobalData *)sharedInstance
{
	if(_instance == nil)
	{
		_instance = [[HOGlobalData alloc] init];
	}
	return _instance;
}




- (void)clearReportLocalInfo
{
	[self clearReportArea];
	[self clearReportDepartment];
	[self clearReportType];
}

- (void)clearReportArea
{
	NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
	[userDefault removeObjectForKey:kHO_FIELD_FaultAreaId];
	[userDefault removeObjectForKey:kHO_FIELD_FaultAreaName];
	[userDefault removeObjectForKey:kHO_FIELD_FaultSubAreaId];
	[userDefault removeObjectForKey:kHO_FIELD_FaultSubAreaName];
	[userDefault removeObjectForKey:kHO_FIELD_FaultThirdAreaId];
	[userDefault removeObjectForKey:kHO_FIELD_FaultThirdAreaName];
	[userDefault synchronize];
}

- (void)clearReportDepartment
{
	
	NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
	[userDefault removeObjectForKey:kHO_FIELD_DepartmentName];
	[userDefault removeObjectForKey:kHO_FIELD_DepartmentId];
	[userDefault synchronize];
}

- (void)clearReportType
{
	NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
	[userDefault removeObjectForKey:kHO_FIELD_FaultTypeName];
	[userDefault removeObjectForKey:kHO_FIELD_FaultSubTypeName];
	[userDefault removeObjectForKey:kHO_FIELD_FaultTypeId];
	[userDefault removeObjectForKey:kHO_FIELD_FaultSubTypeId];
	[userDefault synchronize];
}

- (void)saveDeviceToken:(NSData *)deviceToken
{
	NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
	[userDefaults setObject:deviceToken forKey:@"deviceToken"];
	[userDefaults synchronize];
}

- (void)cleanup
{
	self.caiYunUser = nil;
	[self clearReportLocalInfo];
}

@end
